<template>
    <div class="profile">
        <z-header>账号管理</z-header>
        <section class="profile-content">
            <h3 class="profile-title">当前登录账号</h3>
            <div class="profile-item info">
                <img :src="$store.getters.getAvatarImage">
                <div>
                    <span class="username">{{$store.state.userinfo.username}}</span>
                    <span class="email">邮箱：{{$store.state.userinfo.email}}</span>
                </div>
            </div>
            <router-link tag="div" to="/" class="profile-item">
                <span>修改登录密码</span>
                <i class="iconfont icon-right"></i>
            </router-link>
            <router-link tag="div" to="/" class="profile-item">
                <span>修改个人信息</span>
                <i class="iconfont icon-right"></i>
            </router-link>
            <router-link tag="div" to="/" class="profile-item">
                <span>收货地址管理</span>
                <i class="iconfont icon-right"></i>
            </router-link>
        </section>
        <section class="profile-footer">
            <div class="footer-con">
                <div>
                    <i class="iconfont icon-yijian"></i>
                    <span>意见反馈</span>
                </div>
                <div class="client">
                    <i>ZXG</i>
                    <span>客户端</span>
                </div>
                <div class="logout" @click="userLogout">
                    <i class="iconfont icon-40one"></i>
                    <span>退出登录</span>
                </div>
            </div>
            <p class="zxg">知心购</p>
        </section>
    </div>  
</template>
<script>
import { logout } from '@/http/index';
import zHeader from '@/components/z-header.vue';
export default {
    components: {
        zHeader
    },
    methods: {
        userLogout() {
            
            logout().then(res => {
                 console.log(res,'44444');
                if (res.status == 0) {
                    console.log(res,'++++++');
                    // 删除本地存储的token和用户信息
                    localStorage.removeItem('zxgToken')
                    localStorage.removeItem('userinfo')
                    localStorage.removeItem('avatarImage')
                    this.$store.commit('setUserInfo', null)
                    //购物车数据
                    this.$store.dispatch("getCartData")
                    console.log(this.$store.state.cartList);
                    // 跳转到首页
                    this.$router.replace('/')
                }
            })
             
        },
      
    },
    updated(){
        this.certData()
    }
}
</script>
<style lang="scss"  scoped>
// 公共样式
@import '../../common/style/mixin';
// 单独样式
@import '../../css/profile';
</style>